<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<!-- 引入vue.js -->
		<script src="./js/vue.js"></script>
	</head>
	<body>
		<!-- 1.view层 -->
		<div id="app">
			<button @click="btnChange(-1)" :disabled="n==min?true:false">-</button>
			<span>{{n}}</span>
			<button @click="btnChange(1)" :disabled="n==max?true:false">+</button>
		</div>

		<script type="text/javascript">
			//实例化Vue
			//2.ViewModel层
			var vm = new Vue({
				el: "#app",
				data: {
					n: 0,
					max:10,
					min:0,
				},
				methods: {
					btnChange(k) {
						if(k==1){
							if(this.n < this.max) 
								this.n++;
						}							
							
						if(k==-1){
							if(this.n > this.min)
								this.n--;
						}							
					},					
				},
			});
		</script>


	</body>
</html>
